package com.hspedu.Homework;
/*
 *@auther will
 *@version 1.0
 */

import java.util.Scanner;

public class Homework02 {
    public static void main(String[] args) {
        Get get = new Get();
        get.f1();
    }
}


class Get {
    public  void f1() {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请输入用户名：");
            String username = scanner.next();
            if (username.length() >= 2 && username.length() <= 4) {
                System.out.println("用户名为：" + username);
                break;
            } else {
                System.out.println("输入的用户名长度应该为2或3或4");
            }
        }

        while (true) {
            System.out.println("请输入6位数字的密码");
            Integer password = scanner.nextInt();
            if (password.toString().length() == 6 && isDigital(password)) {
                System.out.println("密码为：" + password);
                break;
            }
        }

        while (true){
            System.out.println("请输入邮箱");
            String email = scanner.next();
            int index_email = email.indexOf("@");
            int index_dot = email.indexOf(".");
            if (index_email!=-1&&index_dot!=-1&&index_dot>index_email){
                System.out.println("你的邮箱是："+email);
                break;
            }
        }
    }

    public boolean isDigital(Integer i) {
        char[] chars = i.toString().toCharArray();
        for (int j = 0; j < chars.length; j++) {
            if (chars[j] < '0' || chars[j] > '9') {
                return false;
            }
        }
        return true;
    }
}